const puppeteer = require('puppeteer');

const jsdom = require('jsdom');

// puppeteer.launch({headless:false,defaultViewport:{width:1366,height:768}}).then((browser)=>{
//     browser.newPage().then(page=>{
//         page.goto('https://www.baidu.com')
//     })
// })

async function run (){
    const browser = await puppeteer.launch({headless:false,defaultViewport:{width:1366,height:768}});
    const page = await browser.newPage();
    await page.goto('https://www.baidu.com');
    const input_area = await page.$("#kw");
    await input_area.type("Hello Wrold");

//    var document = new jsdom(page).window.document;
//    var content = document.getElementById("kw");
//    console.log(page);


    const search_btn = await page.$('#su');
    await search_btn.click();


    console.log("程序执行完毕。");

    await browser.close();
}

run();